<script>
	import {
		mapState
	} from 'vuex';
	export default {
		computed: {
			...mapState('user', ['userinfo'])
		},
		onLoad(){
			const [roles] = this.userinfo.roles || [];
			console.log(roles?.name === 'ROLE_YG');
			if (roles?.name === 'ROLE_YG') {
				// 隐藏tabbar
				uni.hideTabBar();
				// 跳转到员工核销页
				return uni.navigateTo({
					url: '/pages/product/scan'
				});
			}
		},
		
		onLaunch: function() {
			// console.log('App lanch');
		},
		onShow: function() {
			// console.log('App onShow');
			//#ifdef MP-WEIXIN
	

			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(function(res) {
				// 请求完新版本信息的回调
				if (res.hasUpdate) {
					updateManager.onUpdateReady(function(res2) {
						uni.showModal({
							title: '更新提示',
							content: '发现新版本，重启应用生效!',
							showCancel: false,
							buttonText: '确定',
							confirmColor: '#228B22',
							success(res2) {
								if (res2.confirm) {
									updateManager.applyUpdate();
								}
							}
						});
					});
				}
			});

			updateManager.onUpdateFailed(function(res) {
				// 新的版本下载失败
				uni.showModal({
					title: '提示',
					content: '检查到有新版本，但下载失败，请检查网络设置',
					success(res) {
						if (res.confirm) {
							// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
							updateManager.applyUpdate();
						}
					}
				});
			});
			//#endif
		},
		onHide: function() {
			console.log('App Hide');
		}
	};
</script>

<style lang="scss">
	@import '/static/style/mixin.scss';
	@import '/static/style/normalize.scss';
	@import '/static/style/animate.scss';
	@import '/static/style/flex.scss';
	@import '/static/style/common.scss';

	uni-checkbox .uni-checkbox-input {
		border-radius: 50%;
	}

	uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked {
		border: 1rpx solid #228B22;
		background-color: #228B22;
	}

	uni-checkbox .uni-checkbox-wrapper {
		width: 100%;
	}

	uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked:before {
		color: #FFFFFF;
	}

	uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
		border-color: transparent;
	}

	.place {
		height: 40rpx;
		background-color: $nav-bg;
	}

	//navigate
	.navBar {
		background-color: $nav-bg;
		padding: 20rpx 30rpx;

		.navBar_top {
			height: 40rpx;
			line-height: 40rpx;
			font-size: $font-lg;
			color: $nav-text;
			text-align: center;
			margin-bottom: 30rpx;
		}
	}
</style>